﻿using LJ.EventBus.FastDog.Data;
using LJ.EventBus.FastDog.Transport.Abstractions;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJ.EventBus.FastDog.Transport.InMemoryQueue.Internal;

public class InMemoryQueueMessageSender(MemoryQueue memoryQueue, ILogger<InMemoryQueueMessageSender> logger) : ITransport
{

    private readonly MemoryQueue _memoryQueue = memoryQueue;

    private readonly ILogger _logger = logger;
    public Task SendAsync(TransportMessage message, CancellationToken cancellationToken = default)
    {
        cancellationToken.ThrowIfCancellationRequested();

        _memoryQueue.Send(message);

        _logger.LogDebug("Event message [{messageName}] has been published.", message.GetName());

        return Task.CompletedTask;
    }
}